package com.gem.talkbase.service;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.gem.talkbase.bean.Firend;
import com.gem.talkbase.bean.FirendMsg;
import com.gem.talkbase.client.Client;
import com.gem.talkbase.fragment.Fragment_contact;

public class JSON_GetFriendMsgList {
  public static List<FirendMsg> list;
	public List<FirendMsg> fun(String jsonString){
		 JSONObject jsonObject;	
		 System.out.println(jsonString+"77777777777777777777777777777777777777777");
		try {
			jsonObject = new JSONObject(jsonString);
			JSONArray jsonArray = jsonObject.getJSONArray("GetAllFirenMsg");
			list=new ArrayList<FirendMsg>();
			for(int i = 0; i < jsonArray.length(); i++){
				FirendMsg friendmsg = new FirendMsg();
				JSONObject jsonObject2 = jsonArray.getJSONObject(i);
				friendmsg.setFirendid(jsonObject2.getString("firendid"));	
				friendmsg.setMsg(jsonObject2.getString("msg"));	
				friendmsg.setDate(jsonObject2.getString("date"));	
				friendmsg.setUnick(jsonObject2.getString("uimage"));
				friendmsg.setUimage(Client.Image_URL+jsonObject2.getString("unick"));
				list.add(friendmsg);	
			}
		
		} catch (JSONException e) {     
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return list;
		
	}
}
